<?php /*
	
*/ ?>
<?php include("system/config.inc.php");
$donotinclude = 1;
//print_r($_SESSION);
//insert into customer basket

if(isset($_REQUEST['action']) && ($_REQUEST['action'])=="login")
{
	$varusername = mysql_real_escape_string($_REQUEST['email']);
	$varpassword = md5($_REQUEST['password']);
	
	$sqllogin = "SELECT * FROM tblcustomers 
	WHERE varcustemail = '$varusername' AND varcustpassword = '$varpassword' AND intstatus = '1'";
	$result1 = $n02586916_db->select($sqllogin);
	if(count($result1)>0)
	{
		$userid = $result1[0]['intcusid'];
		$_SESSION['memberid'] = $userid;
		$_SESSION["membername"]=$result1[0]['varcustlname']." ".$result1[0]['varcustfname'];
		$cartupdate="UPDATE `tblcustomerbaskets` SET `intcustomerid` = $userid WHERE `varsessionid` = '".session_id()."' ";
		$n02586916_db->edit($cartupdate);
		if(isset($_REQUEST['a']) && trim($_REQUEST['a'])==6)
		{
		header("location:redirect.php?msg=login");
		die();
		}
		else if(isset($_REQUEST['cond']) && ($_REQUEST['cond'])==1)
		{
		header("location:tracking.php?msg=login");
		die();
		}
		else if(isset($_REQUEST['cond']) && ($_REQUEST['cond'])=='chngacc')
		{
		header("location:changeaccountinfo.php?msg=login");
		die();
		}
		else if(isset($_REQUEST['cond']) && ($_REQUEST['cond'])=='newsletter')
		{
		header("location:custnewsletter.php?msg=login");
		die();
		}
		else if(isset($_REQUEST['cond']) && ($_REQUEST['cond'])=='chngpass')
		{
		header("location:changepass.php?msg=login");
		die();
		}
		else
		{
		header("location:thankyoumessage.php?msg=login");
		die();
		}
		
	}
	else
	{
		//$_SESSION['msg'] = "Username/Password Invalid!";
		header("location:customerlogin.php?msg=lnvalid");
		die();
	}
}
?>
<?php include("inc/head.inc.php") ?>
<body>
<table width="824" border="0" cellpadding="0" cellspacing="0"  align="center">
  
  <tr>
    <td class="headerclass"><?php include(INC."top.inc.php") ?></td>
  </tr>
  <tr>
    <td valign="top" class="maincontainer"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr><td valign="top"class="leftmenuback"><?php include(INC."left.inc.php") ?></td>
        <td valign="top">
		<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="23" colspan="2" class="head">
           <div class="pageheader">Welcome, Please login to your account.</div></td>
        </tr>
		
        <tr>
          <td colspan="2" align="center"><span class="msg">
            <?php
  if(isset($_REQUEST['msg']))
  {
  	echo $mess[$_REQUEST['msg']]; 
  }
  ?>
          </span></td>
        </tr>
		<tr><td style="height:5px;"></td></tr>
        <tr>
          <td width="50%" valign="top" style="padding-left:5px;"><table width="98%" height="130" border="0" align="left" cellpadding="0" cellspacing="0" class="prborderbg" style="border:1px solid #CCCCCC;">
		  
            <tr>
              <td valign="top">&nbsp;</td>
              <td valign="top"><span class="font">I am a new customer.<br />
                  <br />
By creating an account you will be able to shop faster, be up to date on an orders status, and keep track of the orders you have previously made</span></td>
            </tr>
            <tr>
              <td align="right" valign="top">&nbsp;</td>
              <td align="right" valign="top">
                
                <br />
                <a href="customer.php" class="continue">SignUp</a></td>
            </tr>
          </table></td>
          <td width="50%">
		  <form name="login" method="post" action="">
		  <table width="98%" height="130" border="0" align="left" cellpadding="0" cellspacing="0" class="prborderbg" style="border:1px solid #CCCCCC;">
            <tr>
              <td height="23" colspan="5" align="center" class="search" bgcolor="#CCCCCC" style="border:1px solid #999999;">Member Login </td>
            </tr>
            <tr>
              <td width="3%" class="font">&nbsp;</td>
              <td width="36%" class="font">E-Mail</td>
              <td width="3%" class="font">:</td>
              <td width="56%" class="font"><input name="email" type="text" class="feature_headingbg" id="email" size="20" /></td>
              <td width="2%" class="font">&nbsp;</td>
            </tr>
            <tr>
              <td class="font">&nbsp;</td>
              <td class="font">Password</td>
              <td class="font">:</td>
              <td class="font"><input name="password" type="password" class="feature_headingbg" id="password" size="20" /></td>
              <td class="font">&nbsp;</td>
            </tr>
            <tr>
              <td colspan="5" align="right" class="continue"><a href="forgotpassword.php" class="continue">Lost Password? </a></td>
            </tr>
            <tr>
              <td colspan="5" align="center"><!--<input name="Submit" type="submit" class="feature_headingbg" value="Sign In" />-->    
			  <input name="action" type="hidden" id="action" value="login" />
			 <a href="#" onClick="document.login.submit();" class="continue"><div style="background-image:url(images/backimg.gif); background-repeat:no-repeat; width:91px; height:22px; padding-top:3px;" align="center">Login</div></a></a></td>
            </tr>
          </table>
		  </form>
		  </td>
        </tr> 
    </table>		
	   </td>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td><?php include "inc/bottom.inc.php"; ?></td>
  </tr>
</table>
</body>
</html>
